<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            margin-left: 100px;
            background: #000;
        }
    </style>
</head>
<body>
<div style="margin-left: 100px;position: relative;">
    <ul>
        <li>
            <div id="box" class="box"></div>
        </li>
    </ul>

</div>
<div id="box2" class="box" style="margin-left: -50px"></div>
<script>

    var box = document.getElementById('box');
    var box2 = document.getElementById('box2');
    console.log(box.offsetLeft);
    console.log(box2.offsetLeft);

</script>
</body>
</html>